if (!GGServer.Class.webUI) GGServer.Class.webUI = {};
GGServer.Class.webUI.Layer = function(objName) {
	var o = this;
    if (objName) {
        o.Lname = objName;
    }
    else {
        o.Lname = "layer";
    }

    o.isDiv = true;
    o.MsgTitle = "<p class=\"hh\">系统提示信息</p>";
    o.isClose = false;
    o.closeWindow = false;
    o.button = "1111";
    o.type = "text";
    o.domain = "d1";
    var tttt;
    var cookie = new GGServer.Class.io.Cookie();
    var sBody = "<div id=\"dialogBoxContent\"></div>";
    var sBox = "<div id='ab2' class='boxout'><div id=\"divTm\" class=\"tm\"></div><div id=\"divBoxin\" class=\"boxin\">{0}" + sBody + "</div></div></div>";

    o.reset = function() {
        if (o.closeWindow) {
            window.close();
            return;
        }
        if (o.isClose) {

            window.location.href = "http://my.58.com/Reg/";
            return;
            //}
        }
        if (o.isDiv) {8
            if ($("#body_pr").length > 0) {
                $("#body_pr").css("display", "none");
            }
        }
        if (tttt != null) {
            clearInterval(tttt);
        }
        if ($("#" + o.button).length > 0) {
            document.getElementById(o.button).disabled = false;
        }
        $('#ab_hhh').css("display", "none");
    }

    o.init = function() {
        if (o.isDiv) {
            o.LayerDiv();
        }
        var oDiv;
        if ($("#ab_hhh").length <= 0) {
            oDiv = document.createElement('div');
            oDiv.id = "ab_hhh";
            document.body.appendChild(oDiv);
        } else {
            oDiv = $("#ab_hhh")[0];
        }
        oDiv.innerHTML = sBox.replace("{0}", o.MsgTitle);
        this.middle("ab_hhh");
    }

    o.event = function(_sMsg, _sOk, _sCancel, _sClose) {
        if (o.isDiv) {
            if ($("#body_pr").length > 0) {
                $('#body_pr').css("display", "block");
            }
        }
        var sMsg, sTitle;
        if (o.type == "iframeHTML") {
        } else {
            switch (_sMsg) {
                case "ErrorHTML":
                    $("#dialogBoxContent").html(o.typeHTML.ErrorHTML);
                    $("#divTm")[0].style.height = o.typeHTML.height;
                    break;
                default:
                    $("#dialogBoxContent").html(_sMsg);
                    break;
            }
        }
        $('#ab_hhh').css("display", "block"); 
    }
    o.closeLoginBox = function() {
        if (o.isDiv) {
            if ($("#body_pr").length > 0) {
                $('#body_pr').css("display", "none");
            }
        }
        $('#ab_hhh').css("display", "none");
    }

    o.moveStart = function(event, _sId) {
        var oObj = document.getElementById(_sId);
        oObj.onmousemove = mousemove;
        oObj.onmouseup = mouseup;
        oObj.setCapture ? oObj.setCapture() : function() { };
        oEvent = window.event ? window.event : event;
        var dragData = { x: oEvent.clientX, y: oEvent.clientY };
        var backData = { x: parseInt(oObj.style.top.replace("px", "")), y: parseInt(oObj.style.left.replace("px", "")) };
        function mousemove() {
            var oEvent = window.event ? window.event : event;
            var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left.replace("px", ""));
            var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top.replace("px", ""));
            if (iLeft > 0 || iTop > 0) {
                oObj.style.left = iLeft + "px";
                oObj.style.top = iTop + "px";
                dragData = { x: oEvent.clientX, y: oEvent.clientY };
            }
        }
        function mouseup() {
            var oEvent = window.event ? window.event : event;
            oObj.onmousemove = null;
            oObj.onmouseup = null;
            if (oEvent.clientX < 1 || oEvent.clientY < 1 || oEvent.clientX > document.body.clientWidth || oEvent.clientY > document.body.clientHeight) {
                oObj.style.left = backData.y + "px";
                oObj.style.top = backData.x + "px";
            }
            oObj.releaseCapture ? oObj.releaseCapture() : function() { };
        }
    }
    o.middle = function(_sId) {
        var d = document.getElementById(_sId);
        d.style.display = '';
        d.style.position = "absolute";
        d.style.width = "450px";
        d.style.zIndex = 99999;
        d.style.left = (document.body.clientWidth / 2) - (d.offsetWidth / 2) + "px";
        d.style.top = o.DialogLoc(d.offsetHeight) + "px";
    }

    o.LoginOR = function(text, xDom) {
        cookie = new GGServer.Class.io.Cookie();
        $("#dialogBoxContent").html(o.typeHTML.LoginOK.replace("{0}",cookie.oget("UserName")));
        tttt = setInterval(o.Lname + '.reset()', 2000);
    }
    o.LayerDiv = function() {
        var divobj;
        if ($("#body_pr").length <= 0) {
            divobj = document.createElement("div");
            divobj.id = "body_pr"; //LayerDiv_GGS
            divobj.style.position = "absolute";
            divobj.style.left = "0pt";
            divobj.style.top = "0pt";
            divobj.style.zIndex = 9999;
            divobj.style.width = "100%";
            divobj.style.backgroundColor = "rgb(0, 0, 0)";
            divobj.style.height = (document.body.scrollHeight + 100) + "px";
            divobj.style.opacity = "0.3";
            if (document.all) {
                divobj.style.filter = "alpha(opacity=30)";
                divobj.innerHTML = '<iframe src="about:blank" frameborder="0" style="position:absolute; visibility:inherit; top:0px; left:0px; width:100%; height:100%; z-index:9999; filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\';"></iframe>';
            }
            document.body.appendChild(divobj);
        }
    }
    o.typeHTML = {
        ErrorHTML: '<div class="xiangsi"><p class="bt"><span class="red"><img src="http://pic2.58.com/images/5_0/ok4848.gif" align="absmiddle" />　信息提交失败！</span></p>' +
                        '<p>您在&quot; <b>北京 - 海淀 - 清河</b> &quot;发布的房屋出租信息&quot; <b>201212一是两角出租，有意速度 </b>&quot;与以下信息重复或过于相似：' +
                        '<blockquote><a href="#" target="_blank">01212一是两角出租，有意速度</a><br /><a href="#" target="_blank">01212一是两角出租，有意速度</a></blockquote></p>' +
                        '<p>58.com不支持用户重复发布类似信息</p><br /><p class="all"><input name="" type="button" value="返回修改" /></p></div>',
        width: '400px',
        height: '225px'

    }

    o.Include = function(title, msg, type) {
        o.MsgTitle = title;
        if (type != null) {
            o.type = type;
        }
        o.init();
        o.event(msg, 'void 0');
    }

    o.DialogLoc = function(h) {
        var dde = document.documentElement;
        if (window.innerWidth) {
            var wh = window.innerHeight;
            var bgY = window.pageYOffset;
        }
        else {
            var wh = dde.offsetHeight;
            var bgY = dde.scrollTop;
        }
        t_DiglogY = (bgY + ((wh - h) / 2));
        return t_DiglogY;
    }
}
//alert(GGServer.Class.webUI.Layer);